package me.zhengjie.pm.taskprogress.domain;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public class WorkhoursDetail  implements Serializable {

    //id
    private int id;

    //员工工号
    private int workerId;

    //员工名称
    private String workerName;
    //项目名称
    private String taskName;

    //项目编号
    private String taskNo;

    //该类工作统计工时
    private int sumWorkhours;

    //该项目所内工时
    private int localWorkhours;

    //该项目所外工时
    private int outerWorkhours;

    //7类工时统计Map key=类型 value = 时长单位小时
    private Map<String,Integer> workTypeHours  = new HashMap<>();

    public void addWorkTypeHours(String workType,int workhours,String address){
        if (this.workTypeHours.containsKey(workType)){
            //有则累加
            int currentHours = this.workTypeHours.get(workType);
            currentHours += workhours;
            this.workTypeHours.put(workType,currentHours);
        }else {
            //没有则直接加
            this.workTypeHours.put(workType,workhours);
        }
        //同时也计算7类总工时
        this.sumWorkhours += workhours;
        if (address == "所内"){
            localWorkhours += workhours;
        }else {
            outerWorkhours += workhours;
        }
    }
}
